/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bs.tableRenderer;

import java.awt.Component;
import javax.swing.JCheckBox;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author Bone
 */
public class BooleanCellRenderer implements TableCellRenderer {

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        JCheckBox ck = new JCheckBox();
        if (value.equals("1") || value.equals("true")) {
            ck.setSelected(true);
        }
        if (value.equals("0") || value.equals("false")) {
            ck.setSelected(false);
        }
        if (value instanceof Short) {
            if (((Short) value).intValue() == 1) {
                ck.setSelected(true);
            } else {
                ck.setSelected(false);
            }
        }
        if (value instanceof Boolean) {
            ck.setSelected((Boolean) value);
        }
        return ck;
    }
}
